package com.ty.controller;


import com.ty.dto.LoginDTO;
import com.ty.dto.UserRegisterDTO;
import com.ty.entity.User;
import com.ty.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController  //Handler
@RequestMapping("/api/user")
public class UserController {
    @Autowired
    private UserService userService;
    @GetMapping("/send/code")
    public int sentCode(String email) {
        return  userService.sentCode(email);
    }
    @PostMapping("/register")
    public int register( @RequestBody UserRegisterDTO  userRegisterDTO) {
        return  userService.register(userRegisterDTO);
    }


    @PostMapping("/login")
    public String login(@RequestBody LoginDTO loginDTO) {
        return  userService.login(loginDTO);
    }


}